import request from '@/utils/request'

const baseurl = '/erp/api/'

export function GetSignleProduct(args) {
  return request({
    url: baseurl + `crawlurl/`,
    headers: { 'content-type': 'application/json' },
    method: 'POST',
    data: args
  })
}

export function GetBatchs() {
  return request({
    url: baseurl + `getbatch/`,
    headers: { 'content-type': 'application/json' },
    method: 'GET'
  })
}

export function GetBatchProducts(args) {
  return request({
    url: baseurl + `getbatchproduct/`,
    headers: { 'content-type': 'application/json' },
    method: 'POST',
    data: args
  })
}

export function UpdateBatchUserProducts(args) {
  return request({
    url: baseurl + `updatebatchproduct/`,
    headers: { 'content-type': 'application/json' },
    method: 'POST',
    data: args
  })
}

export function GetWebs(id, args) {
  return request({
    url: baseurl + `getwebs/${id || ''}${args && ('?' + args) || ''}`,
    headers: { 'content-type': 'application/json' },
    method: 'GET'
  })
}
export function Delete(id) {
  return request({
    url: `/erp/api/getwebs/${id || ''}`,
    method: 'delete'
  })
}

export function Post(data) {
  return request({
    url: '/erp/api/getwebs/',
    headers: { 'content-type': 'application/json' },
    method: 'post',
    data: data
  })
}

export function Put(id, data) {
  return request({
    url: `/erp/api/getwebs/${id || ''}`,
    headers: { 'content-type': 'application/json' },
    method: 'put',
    data: data
  })
}

export function ModifyWeb(args) {
  return request({
    url: baseurl + `modifyWeb/`,
    headers: { 'content-type': 'application/json' },
    method: 'POST',
    data: args
  })
}

export function GetWebItems(args) {
  return request({

    url: `/erp/api/getwebitems/${args && ('?' + args) || ''}`,
    headers: { 'content-type': 'application/json' },
    timeout: 500000,
    method: 'GET'
  })
}

export function UpdateWebItems(args) {
  return request({

    url: `/erp/api/getwebitems/`,
    headers: { 'content-type': 'application/json' },
    timeout: 500000,
    data: args,
    method: 'PUT'
  })
}

export function DeleteWebItems(id, args) {
  return request({
    url: `/erp/api/deletewebitems/${id || ''}`,
    method: 'delete',
    data: args
  })
}

export function DeleteUploadTask(id) {
  return request({
    url: `/erp/api/deleteuploadtask/${id || ''}`,
    method: 'delete'
  })
}

export function SearchSimilarFromBaidu(args) {
  return request({
    url: baseurl + `searchbaidu/`,
    headers: { 'content-type': 'application/json' },
    method: 'POST',
    timeout: 10000,
    data: args
  })
}

export function UpdateWebCategory(args) {
  return request({
    url: baseurl + `updatewebcategory/`,
    headers: { 'content-type': 'application/json' },
    method: 'POST',
    data: args
  })
}

export function GetWebCategory(id, args) {
  return request({
    url: `/erp/api/getwebcategory/${id || ''}${args && ('?' + args) || ''}`,
    method: 'get'
  })
}

export function SyncProductInfo(id) {
  return request({
    url: `/erp/api/sync_product_info/${id || ''}`,
    method: 'get'
  })
}

export function add_crawl_product_to_task(args) {
  return request({
    url: baseurl + `add_crawl_product_to_task/`,
    headers: { 'content-type': 'application/json' },
    method: 'POST',
    data: args,
    timeout: 90000
  })
}

export function edit_product_attr_from_crawl(id, data) {
  return request({
    url: baseurl + `crawl_product_attr/${id || ''}`,
    headers: { 'content-type': 'application/json' },
    method: 'post',
    data: JSON.stringify(data),
    timeout: 90000
  })
}

export function put_product_from_crawl(id, data) {
  return request({
    url: `/erp/api/crawl_product/${id || ''}`,
    headers: { 'content-type': 'application/json' },
    method: 'put',
    data: JSON.stringify(data),
    timeout: 15000
  })
}

export function crawl_product_dt(args) {
  return request({
    url: `/erp/api/crawl_product_dt/`,
    method: 'POST',
    data: args
  })
}

export function fetch_entity_category(args) {
  return request({
    url: `/erp/api/fetch_entity_category/`,
    method: 'POST',
    data: args
  })
}

export function delete_task(id, args) {
  return request({
    url: `/erp/api/crawl_product/${id || ''}`,
    headers: { 'content-type': 'application/json' },
    method: 'DELETE',
    timeout: 100000,
    data: args
  })
}

export function crawl_modify_remote(args) {
  return request({
    url: `/erp/api/crawl_modify_remote/`,
    headers: { 'content-type': 'application/json' },
    method: 'post',
    timeout: 100000,
    data: args
  })
}

export function crawl_modify_local(args) {
  return request({
    url: `/erp/api/crawl_modify_local/`,
    headers: { 'content-type': 'application/json' },
    method: 'post',
    timeout: 100000,
    data: args
  })
}

export function crawl_save_as_new(args) {
  return request({
    url: `/erp/api/crawl_save_as_new/`,
    headers: { 'content-type': 'application/json' },
    method: 'post',
    timeout: 100000,
    data: args
  })
}

export function crawl_update_directly_upload_remote(args) {
  return request({
    url: `/erp/api/crawl_update_directly_upload_remote/`,
    headers: { 'content-type': 'application/json' },
    method: 'post',
    timeout: 100000,
    data: args
  })
}

export function crawl_product_batch_edit(args) {
  return request({
    url: baseurl + `crawl_product_batch_edit/`,
    headers: { 'content-type': 'application/json' },
    method: 'POST',
    data: args,
    timeout: 10000
  })
}

export function template_add_item_to_task(args) {
  return request({
    url: baseurl + `template_add_item_to_task/`,
    headers: { 'content-type': 'application/json' },
    method: 'POST',
    data: args,
    timeout: 90000
  })
}

export function batch_item_remove_bg(args) {
  return request({
    url: baseurl + `batch_item_remove_bg/`,
    headers: { 'content-type': 'application/json' },
    method: 'POST',
    data: args,
    timeout: 90000
  })
}

export function direct_add_item_to_task(args) {
  return request({
    url: baseurl + `direct_add_item_to_task/`,
    headers: { 'content-type': 'application/json' },
    method: 'POST',
    data: args,
    timeout: 90000
  })
}

export function Sync(mode, id, force) {
  return request({
    url: `${baseurl}crawl_sync/${mode}/${id || ''}/${force || 0}`,
    method: 'post',
    timeout: 150000
  })
}

export function crawl_keyword_page(id) {
  return request({
    url: `${baseurl}crawl_crawl_keyword_page/${id || ''}`,
    method: 'post',
    timeout: 150000
  })
}

export function CrawlProductCount(id, args) {
  return request({
    url: `/erp/api/crawl_product_count/${id || ''}${args && ('?' + args) || ''}`,
    method: 'get'
  })
}

export function delete_remote_product(data) {
  return request({
    url: `/erp/api/del_remote_product/`,
    headers: { 'content-type': 'application/json' },
    method: 'POST',
    data: data,
    timeout: 150000
  })
}
